<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- 
  - Author(s): houfy
  - Date: 2014-12-12 17:12:31
  - Description:
-->
<head>
<title>附件</title>
    <%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp" %>
    <script src="<%=request.getContextPath()%>/crm/js/uploadify/js/jquery-1.9.1.js" type="text/javascript"></script>
	<script src="<%=request.getContextPath()%>/crm/js/uploadify/js/jquery.uploadify-src.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/crm/js/uploadify/css/uploadify.css">
	<style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
    <%
      // 设置上传文件路径
		Date date = new Date();
	    SimpleDateFormat formatStr = new SimpleDateFormat("yyyyMMdd");        
	    String strDate = formatStr.format(date); 
    	//String targetPath ="process/"+strDate;
    	String targetPath = absolutePath + Constants.UPLOADPATH + "process/" + strDate + "/";
    	
    	//附件id
 	 	String ids = "";
		if(request.getParameter("ids")!=null){
			ids = (String)request.getParameter("ids");
		}
     %>
</head>
<body>
    <div id="attachmentDatagrid" class="nui-datagrid" style="width:100%;height:99%" 
	     idField="id" url="com.atozsoft.crm.common.queryUplodeFileListByIds.biz.ext" allowResize="false" dataField="crmFiles" allowResize="false" pageSize="5" showPager="true"
	     showReloadButton="false" totalField="total" multiSelect="true">
         <div property="columns">
            <div field="fileid"   visible="false"></div>
            <div field="filepath" visible="false"></div>
	        <div type="indexcolumn" headerAlign="center" width="20px" align="center">序号</div>
	        <div field="uploadname" headerAlign="center" allowSort="true" renderer="renderOnfileName" >附件名称</div>
	    </div>
    </div>  
    <script type="text/javascript">
		//附件超链
        function renderOnfileName(e) {
            var record = e.record;
            return "<a href='javascript:download(\""+record.filepath+"\",\""+record.uploadname+"\")'>"+record.uploadname+"</a>";
        }
        
		/*
		*附件下载
		*filePath:提示信息
		*fileName:提示信息
		*/
	  	function download(filePath, fileName){
	  		window.location.href = "<%=request.getContextPath()%>/downloadFile?filePath="+filePath+"&fileName="+fileName;
	  	}
	  	
	  	nui.parse();
	  	var ids = "<%=ids %>";
	  	var attgrid = nui.get("attachmentDatagrid");
	  	attgrid.load({ids:ids});
		attgrid.sortBy("fileid", "desc");
    </script>
</body>
</html>